<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>简途旅行</title>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/old/css/flavor/fetch.scss?__inline" media="screen" title="no_title" charset="utf-8">
</head>
<body style="visibility: hidden;">
<div class="wrap">
    <div class="act_header">
        <img src="https://images.simpletour.com/activity/flavor/header_bg@3x.png" alt=""/>
    </div>
    <div class="act_content">
        <img class="bonus" src="https://images.simpletour.com/activity/flavor/bonus_bg@3x.png" alt=""/>
        <div class="input_group">
            <input name="mobile" type="text" placeholder="请输入手机号"/>
            <span class="receive">领取</span>
        </div>
    </div>
    <div class="act_footer">
        <div class="rule">
            <div class="rule-title">
                <span class="title">活动规则</span>
            </div>
            <div class="rule-content">
                1、输入手机号，点击领取，即可领取现金优惠券<br/>
                2、同一个商品只可使用一张优惠券<br/>
                3、使用优惠券和领取优惠券的手机号码需一致<br/>
                4、优惠券仅对简途制定商品可用，不予折现<br/>
                5、优同一个商品只可使用一张优惠券<br/>
                6、10元优惠券为订单总价满100以上使用<br/>
                7、20元优惠券为订单总价满150以上使用
            </div>
            <a class="jump">舌尖上的年味行</a>
        </div>
    </div>
</div>
<div class="alert-modal-wrap success">
    <div class="alert-modal-overlay"></div>
    <div class="alert-modal">
        <div class="modal-content">
            <div class="success">
                <p>您已成功领取<span class="money">30</span>元现金优惠券</p>
                <img src="/old/images/flavor/coupon_group@3x.png" alt=""/>
            </div>
            <a class="to_use">点击一下,马上用券</a>
        </div>
    </div>
</div>
<div class="alert-modal-wrap fail">
    <div class="alert-modal-overlay"></div>
    <div class="alert-modal">
        <div class="modal-content">
            <div class="fail">您已领取过,不要贪心哦</div>
            <a class="to_use">点击一下,马上用券</a>
        </div>
    </div>
</div>
<script type="text/javascript" src="/old/common/js/zepto.min.js"></script>
<script type="text/javascript" src="/old/common/js/base.js"></script>
<script>
    (function (doc, win) {
        var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    // 针对uc横竖屏rem html没有重绘的问题
                    var style;
                    if (style = document.getElementById("forhtml")) {
                        style.parentNode.removeChild(style);
                    }
                    style = document.createElement("style");
                    style.id = "forhtml";
                    document.head.appendChild(style);
                    style.appendChild(document.createTextNode("html{font-size:" + 20 * (clientWidth / 320) + "px !important;}"));
                };
        recalc();
        document.body.style.visibility = 'visible';
        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
        var a = document.getElementsByTagName('a');
        for (var i = 0; i < a.length; i++) {
            a[i].addEventListener('touchstart', function () {
            }, false);
        }
    })(document, window);
    $(document).ready(function () {
        var $wrap = $('.alert-modal-wrap');
        //领取优惠券
        $('.input_group .receive').click(function (e) {
            e.preventDefault();
            var $this = $(this);
            if (!$this.hasClass('disabled')) {
                var mobile = $.trim($('input[name=mobile]').val());
                $this.addClass('disabled');
                if (!mobile) {
                    $.alert({
                        msg: '手机号不能为空!'
                    });
                    $this.removeClass('disabled');
                }else if (!/^0?(13|14|15|17|18)[0-9]{9}$/.test(mobile)) {
                    $.alert({
                        msg: '手机号格式错误'
                    });
                    $this.removeClass('disabled');
                }else {
                    //提交代码
                    $.ajax({
                        type: 'POST',
                        url: '/mobile/gateway/${type}/activity/flavor/fetch',
                        data: {mobile: mobile},
                        success: function (data) {
                            if (data.code == 0) {
                                $('.success').show();
                                $('.success .money').text(data.data.money);
                                $wrap.show();
                            }else if(data.code == 2){
                                $('.fail').show();
                                $wrap.show();
                            }else {
                                $.confirm({
                                    title: '领取失败',
                                    detail: [data.msg],
                                    yes: '确认',
                                    yesFun: function () {
                                    }
                                });
                                $this.removeClass('disabled');
                            }
                        },
                        error: function (data) {
                            $this.removeClass('disabled');
                            $.alert({
                                msg: '网络异常,请重试'
                            });
                        }
                    })
                }
            }
        });
    });
</script>
</body>
</html>